New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/myst 708 kill switch #330
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ConnectOptions as jsonstructure has meaning in endpoints only. Connection manager should at least define own "feature" options, and openvpn client config should define only fine grained methodds like setConnectRetry(infinte). Don't trash the same dto through the system
core/connection/interface.go
Outdated
@@ -19,6 +19,7 @@ package connection | |||
|
|||
import ( | |||
"github.com/mysteriumnetwork/node/communication" | |||
dto2 "github.com/mysteriumnetwork/node/core/node/dto" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid generic packages like DTO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like dto69
more :)
core/connection/interface.go
Outdated
@@ -31,12 +32,12 @@ type DialogCreator func(consumerID, providerID identity.Identity, contact dto.Co | |||
|
|||
// VpnClientCreator creates new vpn client by given session, | |||
// consumer identity, provider identity and uses state callback to report state changes | |||
type VpnClientCreator func(session.SessionDto, identity.Identity, identity.Identity, state.Callback) (openvpn.Process, error) | |||
type VpnClientCreator func(session.SessionDto, identity.Identity, identity.Identity, state.Callback, dto2.ConnectOptions) (openvpn.Process, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Connection manager should not depend on external Connect options. At least define them in the same package
openvpn/client_config.go
Outdated
@@ -26,6 +27,13 @@ type ClientConfig struct { | |||
*config.GenericConfig | |||
} | |||
|
|||
// SetConnectOptions sets connect options provided through endpoint parameters | |||
func (c *ClientConfig) SetConnectOptions(options dto.ConnectOptions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Client config should have clear methods -> RestrictReconnects and so on, dont add external dependency as ConnectOptions
cmd/commands/cli/command.go
Outdated
@@ -23,6 +23,8 @@ import ( | |||
"log" | |||
"strings" | |||
|
|||
"strconv" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 2 separations?
core/connection/interface.go
Outdated
@@ -19,6 +19,7 @@ package connection | |||
|
|||
import ( | |||
"github.com/mysteriumnetwork/node/communication" | |||
dto2 "github.com/mysteriumnetwork/node/core/node/dto" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like dto69
more :)
core/connection/manager.go
Outdated
@@ -71,7 +72,7 @@ func NewManager(mysteriumClient server.Client, dialogCreator DialogCreator, | |||
} | |||
} | |||
|
|||
func (manager *connectionManager) Connect(consumerID, providerID identity.Identity) (err error) { | |||
func (manager *connectionManager) Connect(consumerID, providerID identity.Identity, options dto2.ConnectOptions) (err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+100 for DTO, I am doing same wiith serviceOptions
for vpn server
core/node/dto/connect_options.go
Outdated
|
||
// ConnectOptions holds tequilapi connect options | ||
// swagger:model ConnectOptionsDTO | ||
type ConnectOptions struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets have this DTO in connection
package
e2e/wallet_helper.go
Outdated
@@ -35,6 +32,9 @@ import ( | |||
"github.com/ethereum/go-ethereum/ethclient" | |||
"github.com/ethereum/go-ethereum/params" | |||
"github.com/mysteriumnetwork/node/tequilapi/client" | |||
"github.com/mysteriumnetwork/payments/cli/helpers" | |||
mysttoken "github.com/mysteriumnetwork/payments/mysttoken/generated" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 good idea
openvpn/client_config.go
Outdated
|
||
err := NewDefaultValidator().IsValid(vpnConfig) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
clientFileConfig := newClientConfig(runtimeDir, configDir) | ||
clientFileConfig.SetConnectOptions(options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should map ConnectionOptions
-> openvpn.config
here
tequilapi/client/client.go
Outdated
@@ -100,13 +102,17 @@ func (client *Client) RegistrationStatus(address string) (RegistrationStatusDTO, | |||
} | |||
|
|||
// Connect initiates a new connection to a host identified by providerID | |||
func (client *Client) Connect(consumerID, providerID string) (status StatusDTO, err error) { | |||
func (client *Client) Connect(consumerID, providerID string, disableKill bool) (status StatusDTO, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets have pass all dto.ConnectOptions
as argument
tequilapi/endpoints/connection.go
Outdated
|
||
// connect options | ||
// required: false | ||
ConnectOptions dto.ConnectOptions `json:"connectOptions,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's dont have to repeat connectOptions
in connectionRequest
. IMHO options
would be enought in REST contract
core/connection/interface.go
Outdated
|
||
// Manager interface provides methods to manage connection | ||
type Manager interface { | ||
// Connect creates new connection from given consumer to provider, reports error if connection already exists | ||
Connect(consumerID identity.Identity, providerID identity.Identity) error | ||
Connect(consumerID identity.Identity, providerID identity.Identity, options dto2.ConnectOptions) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+100 for separating openvopn specific things to separate struct
tequilapi/client/client.go
Outdated
ProviderID string `json:"providerId"` | ||
Identity string `json:"consumerId"` | ||
ProviderID string `json:"providerId"` | ||
ConnectOptions dto.ConnectOptions `json:"connectOptions"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's dont have to repeat connectOptions
in connectionRequest
. IMHO options
would be enought in REST contract
f064527
to
ac6af31
Compare
I imagine transformation between
|
deeed2f
to
692f004
Compare
Branch rebased on master |
2c446ef
to
d098d64
Compare
ae5b821
to
924d7fa
Compare
924d7fa
to
6d3226f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTMing this now. But for future reference:
Connection manager should be responsible for tracking service consuming session (promises etc.) and managing underlying payable service. Therefore service abstraction is needed where concrete service will provide and manage all features expected by consumer. I.e. firewall style traffic blocking in case of VPN fails is only needed for Layer3 tunneling. Proxy style service already has it - if proxy conneciton is lost and proxy is set in system settings - no connection will go out by default.
tried to find middle ground between @Waldz and @tadovas remarks.